<template>
  <view class="videoPlay_box">
    <image :src="allList.img" mode="aspectFill" />
    <!-- 分享与静音 -->
    <view class="twoIcons_box">
      <view
        :class="['iconfont', isClick ? 'iconjingyin' : 'iconshengyin']"
        @click="handleShenYin"
      ></view>
      <view class="iconfont iconzhuanfa">
        <button open-type="share"></button>
      </view>
    </view>
    <!-- 视频窗口 -->
    <view class="video_box">
      <video :src="allList.video" objectFit="fill"></video>
    </view>
    <!-- 下载 -->
    <view class="onload_box">
      <view class="text_box" @click="handleDownLoad"> 下载高清 </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      allList: [],
      isClick: false,
    };
  },
  onLoad() {
    this.allList = getApp().globalData.viedo;
  },
  methods: {
    handleShenYin() {
      this.isClick = !this.isClick;
    },
    async handleDownLoad() {
      await uni.showLoading({ 
        title: "下载中",
      });

      const reslut = await uni.downloadFile({
        url: this.allList.video,
      });

      const { tempFilePath } = reslut[1];

      const reslut2 = await uni.saveVideoToPhotosAlbum({
        filePath: tempFilePath,
      });

      uni.hideLoading();
      await uni.showToast({
        title: "下载成功",
      });
    },
  },
};
</script>

<style lang="scss" scope>
.videoPlay_box {
  position: relative;
  width: 100%;
  height: 100vh;
  image {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(10px);
  }
  .twoIcons_box {
    display: flex;
    justify-content: flex-end;
    .iconfont {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      color: #fff;
      font-size: 24px;
      background-color: rgba(0, 0, 0, 0.3);
      display: flex;
      justify-content: center;
      align-items: center;
      margin: 0 15rpx;
    }
    .iconzhuanfa {
      position: relative;
      button {
        position: absolute;
        width: 100%;
        height: 100%;
        left: 0;
        top: 0;
        opacity: 0;
      }
    }
  }
  .video_box {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20rpx 0;
    video {
      width: 380rpx;
      height: 600rpx;
    }
  }
  .onload_box {
    display: flex;
    justify-content: center;
    align-items: center;
    .text_box {
      height: 80rpx;
      width: 380rpx;
      border: 1px solid #fff;
      color: #fff;
      font-size: 16px;
      display: flex;
      justify-content: center;
      align-items: center;
      border-radius: 40rpx;
      background-color: rgba(0, 0, 0, 0.6);
      margin-top: 20rpx;
    }
  }
}
</style>
